<template>
	<view>
		<view class="indexs">
			<view class="header header_wi" :style="'padding-top: ' + navH + 'px;'">
				<view class="header_height" :style="'height:' + gaodu + 'px;line-height:' + gaodu + 'px;top:' + gaodutops + 'px;'">
					<view class="index_h_cont3">
						<view class="index_wenben_img" @tap="jumpzuo"><image :src="imgUrl + '/dzx_img33.png'" mode="widthFix"></image></view>
						<view class="index_wenben">授权页面</view>
					</view>
				</view>
				<view class="coloe_title">s</view>
			</view>
			<view class="shouquan">授权完成，点击返回首页</view>
			<view class="chaxun_center_btn">
				<view class="chaxun_center_btns" @tap="guanbi">{{ $t('checkout.guanbi') }}</view>
			</view>
		</view>
	</view>
	
</template>

<script>
	const app = getApp();
	let request = require('../../utils/require');
    export default {
        data() {
            return {
				navH: app.globalData.navHeight,
				gaodu: app.globalData.height,
				gaodutops: app.globalData.top,
				imgUrl: app.globalData.imgUrl,
            }
        },
		onShow() {
		},
        onLoad(res) {
			this.getUrlCode();
        },
		onReady(){
            uni.setNavigationBarTitle({
                title:this.title
            })
        },
		methods:{
			getUrlParam(code) {
				var reg = new RegExp('(^|&)' + code + '=([^&]*)(&|$)');
				var r = window.location.search.substr(1).match(reg);
				if (r != null) return unescape(r[2]);
				return null;
			},
			guanbi(){
				uni.navigateTo({
					url:"/pages/index/index"
				})
			},
			getUrlCode() {
				var that = this;
				var code = this.getUrlParam('code'); // 截取路径中的code，如果没有就去微信授权，如果已经获取到了就直接传code给后台获取openId
				var local = window.location.href;
				uni.setStorageSync('code',code);
				console.log(code, 8676);
				var redirect_url = encodeURIComponent(local); //回调的地址要编码
				if (code == null || code === '') {
					this.getOpenid();
				} else {
					var data = {
						code: code
					};
					request.post(`index.php?s=/api/user/loginwxTogetOpenid&wxapp_id=` + uni.getStorageSync('web_id'), data).then(result => {
						window.close();
					});
				}
			},
		}
    }
</script>
<style>
	page {
	    background: #f4f8fb;
	}
	.shouquan{
		font-size: 32rpx;
		color: #434343;
		padding: 200rpx 0 0 20px;
	}
	.chaxun_center_list {
	    margin-top: 20rpx;
	    padding: 0 28rpx;
	    background: #fff;
	}
	.chaxun_center_cont {
	    display: flex;
	    align-items: center;
	    justify-content: space-between;
	    padding: 36rpx 0;
	    border-bottom: 1px solid #efefef;
	}
	.chaxun_center_cont:last-child {
	    border-bottom: none;
	}
	.chaxun_center_cont_l {
	    display: flex;
	    align-items: center;
	}
	.chaxun_center_cont_l image {
	    width: 46rpx;
	    height: 46rpx;
	}
	.chaxun_center_cont_l text {
	    font-size: 16px;
	    margin-left: 16rpx;
	    font-weight: 400;
	    color: #333333;
	}
	.chaxun_center_cont_r {
	    display: flex;
	    align-items: center;
	}
	.chaxun_center_cont_r text,
	.chaxun_center_cont_r input {
	    font-size: 28rpx;
	    font-weight: 400;
	    text-align: right;
	    color: #333333;
	}
	.chaxun_center_cont_r image {
	    width: 14rpx;
	    height: 24rpx;
	    margin-left: 16rpx;
	}
	.chaxun_center_btn {
	    margin: 48rpx 46rpx;
	}
	.chaxun_center_btns {
	    width: 100%;
	    text-align: center;
	    font-size: 32rpx;
	    font-weight: 400;
	    padding: 22rpx 0;
	    /* background: linear-gradient(180deg, #3d7cff 0%, #1260ff 100%); */
		background: linear-gradient(180deg, #4ad5ac 0%, #27cc9d 100%);
	    border-radius: 50rpx;
	    color: #ffffff;
	}
	
	.chaxun_center_chaxun {
	    padding: 0 32rpx;
	}
	.chaxun_center_chaxun_title {
	    font-size: 32rpx;
	    font-weight: 600;
	    color: #333333;
	}
	.chaxun_center_chaxun_list {
	    margin-top: 28rpx;
	    position: relative;
	}
	.chaxun_center_chaxun_xianss {
	    background: #d3d3d3;
	    height: 80%;
	    width: 4rpx;
	}
	.chaxun_center_chaxun_xian {
	    position: absolute;
	    left: 15rpx;
	    top: 0;
	    width: 4rpx;
	    height: 100%;
	    display: flex;
	    align-items: center;
	    justify-content: center;
	}
	.chaxun_center_chaxun_cont {
	    display: flex;
	    align-items: center;
	    margin-top: 40rpx;
	}
	.chaxun_center_chaxun_yuan {
	    font-size: 0;
	    z-index: 1;
	}
	.chaxun_center_chaxun_yuan image {
	    width: 32rpx;
	    height: 32rpx;
	}
	.chaxun_center_chaxun_txt {
	    margin-left: 36rpx;
	}
	.chaxun_center_chaxun_t1 {
	    font-size: 24rpx;
	    font-weight: 400;
	    color: #333333;
	    line-height: 36rpx;
	}
	.chaxun_center_chaxun_cont:first-child {
	    margin-top: 0;
	}
	
	.chaxun_center_chaxun_tishi {
	    display: flex;
	    flex-direction: column;
	    justify-content: center;
	    align-items: center;
	    width: 100%;
	    padding-top: 100rpx;
	}
	.chaxun_center_chaxun_tishi image {
	    width: 592rpx;
	    height: 232rpx;
	}
	.chaxun_center_chaxun_tishi text {
	    font-size: 32rpx;
	    color: #777;
	    margin-top: 40rpx;
	}
		
</style>